package javaclass;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

import java.util.Arrays;
@Aspect
@Component
public class VlogUtils {
    @Before("javaclass.UltisLog.aaa()")
    public void before(JoinPoint joinPoint){
        Object[] args = joinPoint.getArgs();
        Signature signature = joinPoint.getSignature();
        String name = signature.getName();
        System.out.println("VlogUtils开始位置,我作用的目标方法是："+name+"，参数是："+ Arrays.asList(args));
    }

    @AfterReturning(value="javaclass.UltisLog.aaa()",returning = "result")
    public void afterreturn(JoinPoint joinPoint,Object result){
        Object[] args = joinPoint.getArgs();
        Signature signature = joinPoint.getSignature();
        String name = signature.getName();
        System.out.println("VlogUtils返回值位置,我作用的目标方法是："+name+"，参数是："+Arrays.asList(args)+"结果是："+result);
    }
    @AfterThrowing(value="javaclass.UltisLog.aaa()",throwing = "exception")
    public void afterthrows(JoinPoint joinPoint,Exception exception){
        Object[] args = joinPoint.getArgs();
        Signature signature = joinPoint.getSignature();
        String name = signature.getName();
        System.out.println("VlogUtils异常位置,我作用的目标方法是："+name+"，参数是："+Arrays.asList(args)+"异常信息是："+exception);
    }
    @After("javaclass.UltisLog.aaa()")
    public void after(JoinPoint joinPoint){
        Object[] args = joinPoint.getArgs();
        Signature signature = joinPoint.getSignature();
        String name = signature.getName();
        System.out.println("VlogUtils结束位置,我作用的目标方法是："+name+"，参数是："+ Arrays.asList(args));
    }
}
